using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleCalendarReminder
{
    /// <summary>
    /// A class which wraps a Google.GData.Calendar.EventEntry object and provides
    /// a more user friendly interface.
    /// </summary>
    public class EventEntryWrapper
    {
        #region Private Data Members

        private Google.GData.Calendar.EventEntry _eventEntry;
        private WhenWrapper[] _times;

        #endregion

        #region Constructors

        /// <summary>
        /// Creates a new instance of the GoogleCalendarReminder.EventEntryWrapper class.
        /// </summary>
        /// <param name="eventEntry">The event entry to wrap.</param>
        /// <exception cref="System.ArgumentNullException">Arguments can't be null.</exception>
        public EventEntryWrapper(Google.GData.Calendar.EventEntry eventEntry)
        {
            if (eventEntry == null)
                throw new ArgumentNullException("Arguments can't be null.");

            _eventEntry = eventEntry;

            List<WhenWrapper> tmpList = new List<WhenWrapper>(_eventEntry.Times.Count);

            foreach (Google.GData.Extensions.When when in _eventEntry.Times)
            {
                tmpList.Add(new WhenWrapper(when));
            }

            _times = tmpList.ToArray();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets the description.
        /// </summary>
        public string Description
        {
            get
            {
                string val = _eventEntry.Content.Content;
                return (val == null ? string.Empty : val);
            }
        }

        /// <summary>
        /// Gets the unique event id.
        /// </summary>
        public string EventId
        {
            get { return _eventEntry.EventId; }
        }

        /// <summary>
        /// Gets the location.
        /// </summary>
        public string Location
        {
            get
            {
                string val = _eventEntry.Locations[0].ValueString;
                return (val == null ? string.Empty : val);
            }
        }

        /// <summary>
        /// Gets the times.
        /// </summary>
        public WhenWrapper[] Times
        {
            get { return _times; }
        }

        /// <summary>
        /// Gets the title.
        /// </summary>
        public string Title
        {
            get
            {
                string val = _eventEntry.Title.Text;
                return (val == null ? string.Empty : val);
            }
        }

        /// <summary>
        /// Gets the uri.
        /// </summary>
        public string Uri
        {
            get
            {
                string val = _eventEntry.AlternateUri.Content;
                return (val == null ? string.Empty : val);
            }
        }

        #endregion
    }
}
